<template>
  <el-container>
    <el-aside width="200">
      <h1 class="logo"></h1>
      <el-menu :collapse="collapse" class="el-lex-menu" :default-active="$route.path">
        <qf-sub-menu :sideMenu="sideMenu"></qf-sub-menu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <el-row type="flex" class="row-bg" justify="space-between">
          <el-col :span="6">
            <div class="grid-content left">
              <i
                @click="collapse = !collapse"
                :class="['iconfont', collapse ? 'icon-xiangyou' : 'icon-shouqi']"
              ></i>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content center">管理系统</div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content right">
              <el-avatar shape="square" :size="40" :src="avatarUrl"></el-avatar>
              <b>
                <svg class="icon" v-if="userInfo.vipLevel" aria-hidden="true">
                  <use :xlink:href="'#' + vipIconName"></use>
                </svg>
                <el-dropdown placement="bottom" @command="command">
                  <span class="nickname" :class="vipIconName + '-i'">
                    {{ userInfo.nickname }}
                    <i style="color: #fff" class="iconfont icon-down"></i>
                  </span>
                  <el-dropdown-menu>
                    <el-dropdown-item
                      divided
                      command="charge"
                      v-if="userInfo.vipLevel"
                      icon="iconfont icon-VIP4"
                      >vip到期时间:<br />{{ vipExpries }}</el-dropdown-item
                    >
                    <el-dropdown-item divided command="charge" icon="iconfont icon-VIP4"
                      >vip充值</el-dropdown-item
                    >
                    <el-dropdown-item
                      divided
                      command="mine"
                      icon="iconfont icon-icon-test"
                      >账号信息</el-dropdown-item
                    >
                    <el-dropdown-item
                      divided
                      command="product"
                      icon="iconfont icon-shangpinguanli"
                      >项目管理</el-dropdown-item
                    >
                    <el-dropdown-item
                      divided
                      icon="iconfont icon-tuichu"
                      @click.native="quit"
                      >退出</el-dropdown-item
                    >
                  </el-dropdown-menu>
                </el-dropdown>
              </b>
              &nbsp;
            </div>
          </el-col>
        </el-row>
      </el-header>
      <el-main>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item
            :to="{ name: bread.name }"
            v-for="bread in breadCrumb"
            :key="bread.name"
          >
            {{ bread.meta.name }}
          </el-breadcrumb-item>
        </el-breadcrumb>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<<script>
import {mapState} from "vuex";
import moment from "moment";
export default {
  computed :{
      ...mapState(["userInfo", "sideMenu" , "breadCrumb"]),
      avatarUrl() {
        return this.userInfo.headimgurl
          ? this.userInfo.headimgurl
          : "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png";
      },
  },

  mounted() {},
  data() {
    return {
      collapse:false,
    };
  },

  methods: {
    command(routerName) {
      if (routerName) {
        this.$router.push({ name: routerName });
      }
    },
    quit() {
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
  }
}
</script>
<style scoped lang="less">
.icon-vip-i,
.icon-vip2-i,
.icon-vip_3-i {
  color: #f4c14f !important;
  font-weight: bolder !important;
}
.icon {
  width: 5em;
  height: 1.5em;
  vertical-align: middle;
}
.el-dropdown-menu,
.el-dropdown-menu__item,
.el-dropdown-menu__item--divided:before {
  color: #074b78;
  text-align: center;
  font-weight: bolder;
}
.el-dropdown-menu {
  width: 200px;
}
.el-header {
  min-height: 60px !important;
  background: #fff;
  color: #01B7D2;
  font-weight: bolder;
  text-align: center;
  line-height: 40px;
  .left {
    text-align: left;

    i {
      font-size: 30px;
      cursor: pointer;
    }
  }
  .center {
    font-size: 30px;
  }
  .el-avatar {
    vertical-align: middle;
    margin-right: 10px;
  }
  .quit {
    color: deeppink;
    text-decoration: underline;
    cursor: pointer;
  }
  .nickname {
    margin-left: 5px;
    color: black;
    cursor: pointer;
  }
}

.el-aside {
  background: #fff;
  color: #333;
  text-align: center;
  .logo {
    min-height: 60px;
    background-image: url(https://static.jianniang.com/moefantasy3/images/HMLogo-2.png);
    background-size: 80%;
    background-repeat: no-repeat;
    background-position-y: center;
    background-position-x: 40%;
  }
  .subMenu {
    text-align: left;
    margin-top:50px;
  }
  /deep/ .el-lex-menu:not(.el-menu--collapse) {
    width: 200px;
    min-height: 500px;
  }
  /deep/ .el-menu-item,
  /deep/ .el-submenu__title {
    color: rgb(78, 91, 248);
  }
  /deep/ .iconfont {
    color: rgb(78, 91, 248);
    font-weight: normal;
  }
  /deep/ .el-menu-item.is-active {
    color: rgb(228, 120, 51);
    .iconfont {
      color: rgb(228, 120, 51);
      font-weight: normal;
    }
  }
}

.el-main {
  background-color: #fff;
  color: #333;
  text-align: center;
  .el-breadcrumb {
    margin-top: 20px;
    margin-bottom: 30px;
  }
}

.el-container {
  margin-bottom: 40px;
  height: 100%;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
}
</style>
